<?php

namespace App\Models\Card ;

use Illuminate\Database\Eloquent\Model;

class CardCouponCodeGive extends Model
{

    protected $table = 'card_coupon_code_give';

    protected $primaryKey = 'id';

    public $timestamps = false;

    public $incrementing = false;


    /**
     * 根据券码查询 是否
     * @param $barcode
     * @return null
     */
    public static function getCodeGive ( $barcode ){

        if (!isset($barcode) || empty($barcode)) {
            return null;
        }

        $code_give = self::where('barcode',$barcode)->first();
        if ( !$code_give ) {
            return null;
        }

        $code_give = $code_give->toArray();

        return $code_give;

    }

}
